﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace tracnghiem
{
    class Database
    {
        DataClassesDataContext context;
        
        public Database()
        {
            context = new DataClassesDataContext();
        }

        public bool isValidUser(String username, String password)
        {            
           var users = 
               from u in context.USERs
               where u.USER_NAME == username && u.PASS_WORD == password
               select u;
           if ( users.Count() > 0)
           {
               return true;
           }
            return false;
        }

        public void addMonHoc(String maMon, String tenMon)
        {
            MON_HOC monhoc = new MON_HOC();
            monhoc.MA_MON = maMon;
            monhoc.TEN_MON = tenMon;
            context.MON_HOCs.InsertOnSubmit(monhoc);
            context.SubmitChanges();            
        }      
        
    }
}
